//
//  PImage.m
//  TuiTe
//
//  Created by 张 霄鹤 on 10-4-12.
//  Copyright 2010 xhzhang. All rights reserved.
//

#import "PImage.h"


@implementation PImage

@synthesize imgData;
@synthesize refCount;

/**
 * 反序列化
 */
- (id)initWithCoder:(NSCoder *)decoder{
	self = [super init];
	NSData *dt = [decoder decodeObjectForKey:@"PIMG"];
	if(dt){
		UIImage *img1 = [[UIImage alloc] initWithData:dt];
		self.imgData = img1;
		[img1 release];
	}
	self.refCount = [decoder decodeIntForKey:@"PREF"];
	return self;
}

/**
 * 序列化
 */
- (void)encodeWithCoder:(NSCoder *)encoder{
	// [encoder encodeObject:title forKey:@"ITITLE"];
	NSData *dt = UIImagePNGRepresentation(self.imgData);
	[encoder encodeObject:dt forKey:@"PIMG"];
	[encoder encodeInt:self.refCount forKey:@"PREF"];
}

- (void)dealloc{
	[imgData release];
	[super dealloc];
}

@end
